15. Code Cells

Code Cells

Most of your work in notebooks will be done in code cells. This is where you write your code and it gets executed. In code cells, you can write any code, assigning variables, defining functions and classes, importing packages, and more. Any code executed in one cell is available in all other cells.

To give you some practice, I created a notebook you can work through. Download the notebook Working With Code Cells below then run it from your own notebook server. Your browser might try to open the notebook file without downloading it. If that happens, right-click on the link then choose "Save Link As…". There are two ways to open the downloaded notebook locally:

  1. In your terminal, change to the directory with the notebook file, then enter jupyter notebook.
  2. If you have a Notebook server already up and running, you can either put the newly-downloaded file into the current working directory or use the “Upload” option in the NOtebook server.

Open a file using the "File" menu.

Open a file using the "File" menu.

Steps to upload any file to the current running Notebook server.

Steps to upload any file to the current running Notebook server.

A snapshot of the `working-with-code-cells.ipynb` file

A snapshot of the working-with-code-cells.ipynb file